using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MyHunter.New
{
    public partial class NewEntity : Form
    {
        #region MEMBERS
        public List<string> CSVList;
        public List<string > CSVListRemove;
        #endregion

        #region CTOR
        public NewEntity(DataSchema.CollectionSchema col, string s)
        {
            InitializeComponent();
            CSVList = new List<string>();
            CSVListRemove = new List<string>();
            openFileDialog.InitialDirectory = s;
            foreach (DataSchema.CollectionSchema.CollectionEntityRow r in col.CollectionEntity.Rows)
            {
                this.listBoxEnities.Items.Add(Engine.Factory.CollectionFactory.BuildEntityListItem(r));
            }
        }
        #endregion

        #region EVENTS
        private void btnCSVFile_Click(object sender, EventArgs e)
        {
            if (this.openFileDialog.ShowDialog() == DialogResult.OK)
            {
                foreach (string path in openFileDialog.FileNames)
                {
                    string fi = path.Substring(path.LastIndexOf("\\") + 1);
                    CSVList.Add(fi);
                    this.listBoxEnities.Items.Add(fi);
                }
            }
        }
        private void buttonRemove_Click(object sender, EventArgs e)
        {
            if(this.listBoxEnities.SelectedIndex >= 0)
            {
                foreach(string s in this.listBoxEnities.SelectedItems)
                {
                    this.CSVListRemove.Add(
                        Engine.Factory.CollectionFactory.ExtractEntityName(s));
                }

                for(int i =this.listBoxEnities.SelectedIndices.Count-1;i>=0; --i)
                {
                    this.listBoxEnities.Items.RemoveAt(this.listBoxEnities.SelectedIndices[i]);
                }
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            this.Close();
        }


        #endregion
    }
}